{include file="public/header" /}
</head>
<body>
	<div id="main-container">
		{include file="public/menu" /}
		<div class="main">
			<div class="notice">{$position.url}</div>
			<div class="main_content">
				<div class="title">
					<span>{$position.name}</span>
				</div>
				<form  class="layui-form layui-form-pane" id="formrec" method="post" role="form">
					<div class="layui-form-item">
			            <label class="layui-form-label">网站名称</label>
			            <div class="layui-input-inline">
			                <input class="layui-input" type="text" name="site_title" value="{:config('sys.site_title')}" placeholder="一般填写公司名称">
			            </div>
			        </div>

			        <div class="layui-form-item">
			            <label class="layui-form-label">网站域名</label>
			            <div class="layui-input-inline">
			                <input class="layui-input" type="text" name="site_url" value="{:config('sys.site_url')}" placeholder="例：www.baidu.com" >
			            </div>
			        </div>

			        <div class="layui-form-item">
			            <label class="layui-form-label">二级域名后缀</label>
			            <div class="layui-input-inline">
			                <input class="layui-input" type="text" name="site_levelurl" value="{:config('sys.site_levelurl')}" placeholder="例：baidu.com" >
			            </div>
			            <font class="font_tip">请正确填写域名后缀，请勿加www，将影响城市分站以及手机站访问</font>
			        </div>
					
					<div class="layui-form-item">
			            <label class="layui-form-label">URL协议</label>
			            <div class="layui-input-inline">
			                <input class="layui-input" type="text" name="site_protocol" value="{:config('sys.site_protocol')}" placeholder="http / https" >
			            </div>
			            <font class="font_tip">请正确填写URL协议，否则页面将无法访问</font>
			        </div>
			        
					<div class="layui-form-item">
	                    <label class="layui-form-label">网站LOGO</label>
	                    <div class="layui-input-inline">
							<input id="path1" class="layui-input" type="text" name="site_logo" value="{:config('sys.site_logo')}"><br>
							<img id="img_path1" class="defimg" src="{:config('sys.site_logo')}" onerror="javascript:this.style.display='none';">
	                    </div>
	                    <div class="layui-input-inline w450">
			            	<input type="button" rel="path1" value="选择站内图片" class="fl BrowerPicture file_btn" />
			            	<div class="site-demo-upload upload-img fl ml5">
				                <div class="site-demo-upbar">
				                    <input type="file" name="file" class="layui-upload-file" id="upload-image">
				                </div>
				        	</div>
			            </div>
	                </div>

					<div class="layui-form-item">
			            <label class="layui-form-label">版权信息</label>
			            <div class="layui-input-inline">
			                <textarea name="site_copyright" placeholder="版权信息" class="layui-textarea w700">{:config('sys.site_copyright')}</textarea>
			            </div>
			        </div>

			        <div class="layui-form-item">
	                    <label class="layui-form-label">后台滑动验证</label>
	                    <div class="layui-input-inline">
	                        <input type="checkbox" {if config('sys.site_slide') eq 1}checked{/if} name="site_slide" lay-skin="switch" lay-filter="switchTest">
	                        <font class="font_tip">如无特殊需求，建议开启</font>
	                    </div>

	                </div>
					{if $indexdef}
					<div class="layui-form-item">
	                    <label class="layui-form-label">引导页</label>
	                    <div class="layui-input-inline w700">
	                        <input type="checkbox" {if config('sys.site_guide') eq 1}checked{/if} name="site_guide" lay-skin="switch" lay-filter="switchTest">
	                    </div>
	                </div>
	                {/if}

	                <!-- <div class="layui-form-item">
	                    <label class="layui-form-label">多图上传</label>
	                    <div class="layui-input-inline w700">
	                    	<input type="hidden" name="imglist" id="imglist">
	                							<div id="upload_imagelist" >上传多图</div>
	                							<div class="picture_tip"></div>
	                				    		<div id="picture_show"></div>
	                    </div>
	                </div> -->


					<div class="layui-form-item">
	                    <label class="layui-form-label"></label>
	                    <div class="layui-input-inline">
			              	<button class="btn" lay-submit="" lay-filter="save" data-href='{:url('basic')}'>提交</button>
	                    </div>
			        </div>
				</form>

			</div>
		</div>
	</div>
<!-- <link rel="stylesheet" href="__ADM_PUBLIC__/css/webuploader.css">
<script type="text/javascript" src="__ADM_PUBLIC__/js/webuploader.js"></script> -->

<script>
layui.use(['form','common','upload'], function(){
        var $ = layui.jquery;
        $form = $('form');
        var form = layui.form(),layer = layui.layer,common=layui.common;

	    /*var picture_show = $('#picture_show');
		var picture_tip = $(".picture_tip");

		var uploader = WebUploader.create({
			auto: true,
			swf:  '__ADM_PUBLIC__/js/Uploader.swf',
			server: '{:url('Upload/upload',['file'=>'file'])}',
			pick: '#upload_imagelist',
			accept:{
				title: 'Images',
				extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/'
			},
			duplicate :true 
		});
											
		uploader.on( 'uploadSuccess', function(file,data){
			if(data.status == 1){
				picture_tip.html(""+ data.image_name +" 上传成功");					
				var img = '/uploads/image/'+data.image_name;
				var picture_html= '<div class="picture_item"><img src="'+ img +'" width="114" height="114"><div class="picture_del">删除</div><div class="picture_go_up">前移</div><input type="hidden" class="imgval" value="'+ img +'" /></div>'
				picture_show.append(picture_html);
				updateimg('imgval', 'imglist');
			}else{
				picture_tip.html(data.state);
			}
		});
*/

        //上传多图
        /*layui.upload({
            url: "{:url('Upload/upload',['file'=>'file'])}" //上传接口
            ,before: function(input){
                console.log('图片上传中');
            }
            ,title:'多图上传'
            ,elem: '#upload-imagelist' //指定原始元素，默认直接查找class="layui-upload-file"
            ,method: 'post' //上传接口的http类型
            ,ext: 'jpg|png|gif'
            ,type:'images'
            ,success: function(data){ //上传成功后的回调
                if(data.status == 1){
					picture_tip.html(""+ data.image_name +" 上传成功");					
					var img = '/uploads/image/'+data.image_name;
					var picture_html= '<div class="picture_item"><img src="'+ img +'" width="114" height="114"><div class="picture_del">删除</div><div class="picture_go_up">前移</div><input type="hidden" class="imgval" value="'+ img +'" /></div>'
					picture_show.append(picture_html);
					updateimg('imgval', 'imglist');
                }else{
                    picture_tip.html(data.state);
                }
            }
        });*/

        //上传图片
        layui.upload({
            url: "{:url('Upload/upload',['file'=>'file'])}" //上传接口
            ,before: function(input){
                //console.log('图片上传中');
            }
            ,title:'上传图片'
            ,elem: '#upload-image' //指定原始元素，默认直接查找class="layui-upload-file"
            ,method: 'post' //上传接口的http类型
            ,ext: 'jpg|png|gif'
            ,type:'images'
            ,success: function(data){ //上传成功后的回调
                if(data.status == 1){
                    $("#path1").val('/uploads/image/'+data.image_name);
                    $("#img_path1").attr('src', '/uploads/image/' + data.image_name).show();
                }else{
                    alert(data.error_info);
                }
            }
        });

        $('.BrowerPicture').click(function(){
        	var path = $(this).attr('rel');
        	layer.open({
			    type: 2,
			    title: '选择站内图片',
			    shadeClose: true,
			    shade: false,
			    anim: 2,
			    area: ['750px', '350px'],
			    content: ['{:url('upload/browsefile', array('stype' => 'picture'))}?docname='+path]
			});
		});

		/*$('#picture_show').on('mouseenter','.picture_item',function(){
				$(this).find('.picture_go_up').show();
				$(this).find('.picture_del').show();
			}).on('mouseleave','.picture_item',function(){
				$(this).find('.picture_go_up').hide();
				$(this).find('.picture_del').hide();
			}
		); 

	    $('#picture_show').on('click','.picture_go_up',function () {
	        var parent = $(this).parent();
	        if (parent.index() == 0){
	        }else{
	        	parent.prev().before(parent);
	        	$(this).hide();
	        	parent.find('.picture_del').hide();
	        }
	        updateimg('imgval', 'imglist');
	    });

	    $('#picture_show').on('click','.picture_del',function () {
	        var img = $(this).next().val();//下个元素input的值 
			$(this).parent().remove();////移除父元素
			updateimg('imgval', 'imglist');
			return;     
	    });*/

        //监听提交
        form.on('submit(save)', function(data){

            var sub = true;
            var url = $(this).data('href');
            if(url){
                if(sub){
                    $.ajax({
                        url: url,
                        type: 'post',
                        dataType: 'json',
                        data: data.field,
                        success: function (info) {
                            if (info.code == 1) {
                                common.layerAlertSHref(info.msg, '提示', "{:url('system/basic')}");
                            }
                            else {
                                common.layerAlertE(info.msg, '提示');
                            }
                        },
                        beforeSend: function () {
                            $(data.elem).attr("disabled", "true").text("提交中...");
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            common.layerAlertE(textStatus, '提示');
                        }
                    });
                }
            }else{
                common.layerAlertE('链接错误！', '提示');
            }
            return false;
        });

    });
/*function updateimg(node,name){
	var num = $('.'+node);
	var valstr = "";
	for(i=0;i<num.length;i++)
	{
		valstr = valstr+num.eq(i).val()+"***";
	}
	$("#"+name).val(valstr);
}*/
</script>
</body>
</html>